﻿using RedisInAction;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace Demo
{
    public class TestBloomFilter
    {

        public static void Test1()
        {
            string Key = "BloomFilter";
            RedisService.RedisFactory.DefaultRedis.Del(Key);
            BloomFilter bloomFilter = new BloomFilter(Key, 10*1024 * 1024 * 8, 10000000, 3);
            for (int i = 0; i < 50000; i++)
            {
                bloomFilter.Add(i.ToString());
            }
            Stopwatch sw = new Stopwatch();
            do
            {
                var c = Console.ReadLine();
                if (c == "q")
                    break;
                sw.Restart();
                var temp = bloomFilter.Exist(c);
                sw.Stop();
                Console.WriteLine($"查找:{c}\n结果:{temp}\n总耗时:{sw.ElapsedMilliseconds}\n错误概率:{bloomFilter.getFalsePositiveProbability()}");
            } while (true);
        }



    }
}
